package logic

import (
	"baidu/baidurpc/baidurpc"
	"context"

	"baidu/api/internal/svc"
	"baidu/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type PwdUpdateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewPwdUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PwdUpdateLogic {
	return &PwdUpdateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *PwdUpdateLogic) PwdUpdate(req *types.PwdUpdateRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line

	register, err := l.svcCtx.BaiDu.PwdUpdate(l.ctx, &baidurpc.PwdUpdateRequest{
		Mobile:   req.Mobile,
		SmsCode:  req.SmsCode,
		Password: req.Password,
		Id:       req.Id,
	})
	if err != nil {
		return &types.Response{
			Message: "修改失败",
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "修改成功",
		Code:    200,
		Data:    register,
	}, nil
}
